package com.keensense.vcm.model;

import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * @author lanjian
 * @date 2020/5/7 2:58 下午
 */
@XmlRootElement(name = "request")
public class NvNRequest {

    private NvNRequest() {}

    public NvNRequest(Integer similarityThreshold, Integer minFrequence, Library libraryA) {
        this.similarityThreshold = similarityThreshold;
        this.minFrequence = minFrequence;
        this.libraryA = libraryA;
    }

    /**
     * 是否异步请求，true 或 false，默认值false
     */
    @XmlElement
    private Boolean isAsync;

    /**
     * 相似度阈值,范围[80,100]
     */
    @XmlElement
    private Integer similarityThreshold;

    /**
     * 最小频度，统计此超过频度及其以上的过脸数据，最小频度可以设置为2,最大频度可以设置为1000
     */
    @XmlElement
    private Integer minFrequence;

    /**
     * 【预留字段】 返回按频度排序的前topN人脸范围上限[1-1000]，默认值1000。
     */
    @XmlElement
    private Integer topN;

    /**
     * 统计的时间间隔，单位为秒，范围[1,300]，默认值为1s
     */
    @XmlElement
    private Integer timeInterval;

    /**
     * 人脸算法，单算法时默认取该算法，多算法时默认取第一个算法
     */
    @XmlElement
    private String algorithmCode;

    /**
     * 超时时间，单位为秒，默认30S。最小值可以设置为3s，最大值可以设置为1200s。执行时间超过1200s的任务建议发异步请求。
     */
    @XmlElement
    private Integer timeout;

    /**
     * 动态或者静态库
     */
    @XmlElement
    private Library libraryA;

    /**
     * 动态或者静态库 预留，本次不实现
     */
    @XmlElement
    private Library libraryB;

    /**
     * 分页信息。异步请求无需传入，同步请求必须传入该字段。
     */
    @XmlElement
    private Page page;

    public void setAsync(Boolean async) {
        isAsync = async;
    }

    public void setTopN(Integer topN) {
        this.topN = topN;
    }

    public void setTimeInterval(Integer timeInterval) {
        this.timeInterval = timeInterval;
    }

    public void setAlgorithmCode(String algorithmCode) {
        this.algorithmCode = algorithmCode;
    }

    public void setTimeout(Integer timeout) {
        this.timeout = timeout;
    }

    public void setLibraryB(Library libraryB) {
        this.libraryB = libraryB;
    }

    public void setPage(Page page) {
        this.page = page;
    }

    public static class Page {

        /**
         * 单次查询页码编号，取值范围为1~100，类型为int
         */
        @XmlElement
        private Integer no;

        /**
         * 单页内显示记录数，取值范围1~1000，类型为int
         */
        @XmlElement
        private Integer size;

        public Page(Integer no, Integer size) {
            this.no = no;
            this.size = size;
        }

        public void setNo(Integer no) {
            this.no = no;
        }

        public void setSize(Integer size) {
            this.size = size;
        }
    }

    public static class Library {

        /**
         * 静态库ID，静态库ID不为空时忽略FaceGroups---预留，本次不实现静态库碰撞
         */
        @XmlElement
        private String libraryID;

        @XmlElementWrapper(name = "faceGroups")
        @XmlElement(name = "faceGroup")
        private List<FaceGroup> faceGroups;

        public Library(String libraryID) {
            this.libraryID = libraryID;
        }

        public Library(List<FaceGroup> faceGroups) {
            this.faceGroups = faceGroups;
        }

        public void setLibraryID(String libraryID) {
            this.libraryID = libraryID;
        }

        public void setFaceGroups(List<FaceGroup> faceGroups) {
            this.faceGroups = faceGroups;
        }
    }

}
